package com.lin;

import java.util.ArrayList;
import java.util.List;

// 顾客类
class Customer {
    private List<Fruit> fruits; // 购买的水果列表

    public Customer() {
        fruits = new ArrayList<>();
    }

    // 添加水果到购物车
    public void addFruit(Fruit fruit) {
        fruits.add(fruit);
    }

    // 添加水果到购物车
    public void addFruit(Fruit fruit,int weight) {
        fruits.add(fruit);
    }

    // 计算所有水果的总价
    public double calculatePrice(Promotion promotion) {
        double price = 0.0;
        for (Fruit fruit : fruits) {
            price += fruit.getPrice();
        }
        price = promotion.calculateDiscount(new Order());
        return price;
    }

    // 计算所有水果的总价
    public double calculatePrice(Promotion promotion,Order order) {
        double price = promotion.calculateDiscount(order);
        order.setTotalPrice(price);
        return price;
    }

}